//
//  LocalTravelRequest.m
//  TongChenTEst
//
//  Created by zheng ji on 14-2-22.
//  Copyright (c) 2014年 jxw. All rights reserved.
//

#import "LocalTravelRequest.h"
#import "LocalTravelConfig.h"
@implementation LocalTravelRequest

+(NSString*)searchScenery:(NSString*)cityId themeId:(NSString*)themeId keyWord:(NSString*)keyWord longitude:(NSString*)longitude latitude:(NSString*)latitude radius:(int) radius page:(int)page pageSize:(int)pageSize{
    NSString* serviceName=@"GetSceneryList";
    
    NSString* requestHeader=[self getRequestHeader:serviceName];
    
    NSMutableString* requestXml=[[NSMutableString alloc]init];
    
    [requestXml appendString:@"<?xml version='1.0' encoding='utf-8' standalone='yes'?>"];
    [requestXml appendString:@"<request>"];
    [requestXml appendString:requestHeader];
    
    [requestXml appendString:@"<body>"];
    
    [requestXml appendFormat:@"<clientIp>%@</clientIp>",[LocalTravelConfig getClientIPForTongCheng]];
    
    if(cityId !=nil && ![cityId isEqualToString:@"" ]){
        [requestXml appendFormat:@"<cityId>%@</cityId>",cityId];
    }
    
    if(keyWord !=nil && ![keyWord isEqualToString:@"" ]){
        [requestXml appendFormat:@"<keyword>%@</keyword>",keyWord];
        [requestXml appendFormat:@"<searchFields>%@</searchFields>",@"sceneryName"];
    }
    
    
    
    
    [requestXml appendFormat:@"<page>%d</page>",page];
    [requestXml appendFormat:@"<pageSize>%d</pageSize>",pageSize];
    
    if(themeId !=nil && ![themeId isEqualToString:@""] && ![themeId isEqualToString:@"0"]){
        [requestXml appendFormat:@"<themeId>%@</themeId>",themeId];
    }
    
    [requestXml appendFormat:@"<cs>%@</cs>",@"2"];
    
    if(radius>0){
        if(latitude !=nil && ![latitude isEqualToString:@"" ]){
            [requestXml appendFormat:@"<latitude>%@</latitude>",latitude];
        }
        if(longitude !=nil && ![longitude isEqualToString:@"" ]){
            [requestXml appendFormat:@"<longitude>%@</longitude>",longitude];
        }
        if(radius>0){
            [requestXml appendFormat:@"<radius>%d</radius>",radius];
        }
    } 
    
    [requestXml appendString:@"</body>"];
    [requestXml appendString:@"</request>"];
    
    NSString *returnXml = [self sendRequest:requestXml];
    
    return  returnXml   ;
}



/**
 获取景点交通信息
 sceneryId : 景点ID
 */
+(NSString*)getSceneryTrafficInfo:(NSString*)sceneryId{
    NSString* serviceName=@"GetSceneryTrafficInfo";
    
    NSString* requestHeader=[self getRequestHeader:serviceName];
    
    NSMutableString* requestXml=[[NSMutableString alloc]init];
    
    [requestXml appendString:@"<?xml version='1.0' encoding='utf-8' standalone='yes'?>"];
    [requestXml appendString:@"<request>"];
    [requestXml appendString:requestHeader];
    
    [requestXml appendString:@"<body>"];
    
    //[requestXml appendFormat:@"<clientIp>%@</clientIp>",[LocalTravelConfig getClientAPIForTongCheng]];
    [requestXml appendFormat:@"<sceneryId>%@</sceneryId>",sceneryId];

    
    [requestXml appendString:@"</body>"];
    [requestXml appendString:@"</request>"];

        NSString *returnXml = [self sendRequest:requestXml];
    
    return  returnXml  ;
}
/**
 获取景点详细介绍
 sceneryId : 景点ID
 cc: 坐标系统 1: 图吧 2：百度
 */
+(NSString*)getSceneryDetail:(NSString*)sceneryId cc:(NSString*) cc{
    NSString* serviceName=@"GetSceneryDetail";
    
    NSString* requestHeader=[self getRequestHeader:serviceName];
    
    NSMutableString* requestXml=[[NSMutableString alloc]init];
    
    [requestXml appendString:@"<?xml version='1.0' encoding='utf-8' standalone='yes'?>"];
    [requestXml appendString:@"<request>"];
    [requestXml appendString:requestHeader];
    
    [requestXml appendString:@"<body>"];
 
    [requestXml appendFormat:@"<sceneryId>%@</sceneryId>",sceneryId];
    [requestXml appendFormat:@"<cc>%@</cc>",cc];
    
    [requestXml appendString:@"</body>"];
    [requestXml appendString:@"</request>"];
       NSString *returnXml = [self sendRequest:requestXml];
 
    return  returnXml   ;

}

/**
 获取周边景点
 sceneryId : 景点ID
 
 */
+(NSString*)getNearbyScenery:(NSString*)sceneryId page:(int)page pageSize:(int) pageSize{
    NSString* serviceName=@"GetNearbyScenery";
    
    NSString* requestHeader=[self getRequestHeader:serviceName];
    
    NSMutableString* requestXml=[[NSMutableString alloc]init];
    
    [requestXml appendString:@"<?xml version='1.0' encoding='utf-8' standalone='yes'?>"];
    [requestXml appendString:@"<request>"];
    [requestXml appendString:requestHeader];
    
    [requestXml appendString:@"<body>"];
    
 
    [requestXml appendFormat:@"<sceneryId>%@</sceneryId>",sceneryId];
    [requestXml appendFormat:@"<page>%d</page>",page];
    [requestXml appendFormat:@"<pageSize>%d</pageSize>",pageSize];
    [requestXml appendString:@"</body>"];
    [requestXml appendString:@"</request>"];
    
    NSString *returnXml = [self sendRequest:requestXml];
 
    return  returnXml   ;
}
/**
 获取景点图片列表
 sceneryId : 景点ID
 
 */
+(NSString*)getSceneryImageList:(NSString*)sceneryId page:(int)page pageSize:(int) pageSize{
    NSString* serviceName=@"GetSceneryImageList";
    
    NSString* requestHeader=[self getRequestHeader:serviceName];
    
    NSMutableString* requestXml=[[NSMutableString alloc]init];
    
    [requestXml appendString:@"<?xml version='1.0' encoding='utf-8' standalone='yes'?>"];
    [requestXml appendString:@"<request>"];
    [requestXml appendString:requestHeader];
    
    [requestXml appendString:@"<body>"];
    
    
    [requestXml appendFormat:@"<sceneryId>%@</sceneryId>",sceneryId];
    [requestXml appendFormat:@"<page>%d</page>",page];
    [requestXml appendFormat:@"<pageSize>%d</pageSize>",pageSize];
    [requestXml appendString:@"</body>"];
    [requestXml appendString:@"</request>"];
    
    NSString *returnXml = [self sendRequest:requestXml];
 
    return  returnXml   ;
}
/**
 获取景点价格信息
 sceneryIds : 景点ID，多个ID之间用逗号分隔，最多20个
 showDetail: 1 :返回详细，2:简单
 useCache：0 :不使用缓存，1： 使用缓存
 */
+(NSString*)getSceneryPrice:(NSString*)sceneryIds showDetail:(int)showDetail useCache:(int) useCache{
    NSString* serviceName=@"GetSceneryPrice";
    
    NSString* requestHeader=[self getRequestHeader:serviceName];
    
    NSMutableString* requestXml=[[NSMutableString alloc]init];
    
    [requestXml appendString:@"<?xml version='1.0' encoding='utf-8' standalone='yes'?>"];
    [requestXml appendString:@"<request>"];
    [requestXml appendString:requestHeader];
    
    [requestXml appendString:@"<body>"];
    
    [requestXml appendFormat:@"<showDetail>%d</showDetail>",showDetail];
    [requestXml appendFormat:@"<sceneryIds>%@</sceneryIds>",sceneryIds];
    
    [requestXml appendFormat:@"<useCache>%d</useCache>",useCache];
    [requestXml appendString:@"</body>"];
    [requestXml appendString:@"</request>"];
    
    NSString *returnXml = [self sendRequest:requestXml];
 
    return  returnXml   ;

}
/**
 获取景区价格日历数据
 policyId: 价格策略ID
 startDate: 起始日期，格式:2012-07-01
 endDate: 暂未启用
 showDetail: 0 不显示详细，1 显示详细
 */
+(NSString*)getPriceCalendar:(NSString*)policyId startDate:(NSString*) startDate endDate:(NSString*)endDate showDetail:(int)showDetail{
    NSString* serviceName=@"GetPriceCalendar";
    
    NSString* requestHeader=[self getRequestHeader:serviceName];
    
    NSMutableString* requestXml=[[NSMutableString alloc]init];
    
    [requestXml appendString:@"<?xml version='1.0' encoding='utf-8' standalone='yes'?>"];
    [requestXml appendString:@"<request>"];
    [requestXml appendString:requestHeader];
    
    [requestXml appendString:@"<body>"];
    [requestXml appendFormat:@"<policyId>%@</policyId>",policyId];
    [requestXml appendFormat:@"<startDate>%@</startDate>",startDate];
    [requestXml appendFormat:@"<endDate>%@</endDate>",endDate];
    [requestXml appendFormat:@"<showDetail>%d</showDetail>",showDetail];
    

    [requestXml appendString:@"</body>"];
    [requestXml appendString:@"</request>"];
    
    NSString *returnXml = [self sendRequest:requestXml];
   
    return  returnXml  ;
}
/**
 获取指定城市的景点列表
 
 */
+(NSString*)getSceneryListByCityId:(NSString*)cityId page:(int)page pageSize:(int) pageSize{
    return [LocalTravelRequest getSceneryListByCityId:cityId page:page pageSize:pageSize latitude:nil longitude:nil radius:0];
}

/**
 获取指定城市的景点列表
 latitude :纬度 ，用于查询指定半径范围内经度，不指定忽略
 longitude:经度 ，用于查询指定半径范围内经度 不指定忽略
 radius :半径长度，单位：米 ；0 忽略
 */
+(NSString*)getSceneryListByCityId:(NSString*)cityId page:(int)page pageSize:(int) pageSize latitude:(NSString*)latitude longitude:(NSString*) longitude radius:(NSString*)radius{
    NSString* serviceName=@"GetSceneryList";
    
    NSString* requestHeader=[self getRequestHeader:serviceName];
    
    NSMutableString* requestXml=[[NSMutableString alloc]init];
    
    [requestXml appendString:@"<?xml version='1.0' encoding='utf-8' standalone='yes'?>"];
    [requestXml appendString:@"<request>"];
    [requestXml appendString:requestHeader];
    
    [requestXml appendString:@"<body>"];
    
    [requestXml appendFormat:@"<clientIp>%@</clientIp>",[LocalTravelConfig getClientIPForTongCheng]];
    if(cityId !=nil && ![cityId isEqualToString:@""]){
       [requestXml appendFormat:@"<cityId>%@</cityId>",cityId];
    }
    [requestXml appendFormat:@"<page>%d</page>",page];
    [requestXml appendFormat:@"<pageSize>%d</pageSize>",pageSize];
    [requestXml appendFormat:@"<cs>%@</cs>",@"2"];
    if(radius>0){
      if(latitude !=nil && ![latitude isEqualToString:@"" ]){
         [requestXml appendFormat:@"<latitude>%@</latitude>",latitude];
       }
      if(longitude !=nil && ![longitude isEqualToString:@"" ]){
         [requestXml appendFormat:@"<longitude>%@</longitude>",longitude];
       }
      if(radius>0){
         [requestXml appendFormat:@"<radius>%@</radius>",radius];
      }
    }
    
    [requestXml appendString:@"</body>"];
    [requestXml appendString:@"</request>"];
    
    NSString *returnXml = [self sendRequest:requestXml];
  
    return  returnXml   ;
}

/**
 获取指定城市,主题的景点列表
 */
+(NSString*)getSceneryListByCityIdThemeId:(NSString*)cityId themeId:(NSString*) themeId page:(int)page pageSize:(int) pageSize{
    NSString* serviceName=@"GetSceneryList";
    
    NSString* requestHeader=[self getRequestHeader:serviceName];
    
    NSMutableString* requestXml=[[NSMutableString alloc]init];
    
    [requestXml appendString:@"<?xml version='1.0' encoding='utf-8' standalone='yes'?>"];
    [requestXml appendString:@"<request>"];
    [requestXml appendString:requestHeader];
    
    [requestXml appendString:@"<body>"];
    
    [requestXml appendFormat:@"<clientIp>%@</clientIp>",[LocalTravelConfig getClientIPForTongCheng]];
    if(cityId !=nil && ![cityId isEqualToString:@""]){
        [requestXml appendFormat:@"<cityId>%@</cityId>",cityId];
    }
    if(themeId !=nil && ![themeId isEqualToString:@""] && ![themeId isEqualToString:@"0"]){
       [requestXml appendFormat:@"<themeId>%@</themeId>",themeId];
    }
    [requestXml appendFormat:@"<page>%d</page>",page];
    [requestXml appendFormat:@"<pageSize>%d</pageSize>",pageSize];
    [requestXml appendFormat:@"<cs>%@</cs>",@"2"];
    [requestXml appendString:@"</body>"];
    [requestXml appendString:@"</request>"];
    
    NSString *returnXml = [self sendRequest:requestXml];
  
    return  returnXml   ;

}
/**
 按照关键词搜索指定城市的景区
 */
+(NSString*)searchSceneryByKeyWordInCity:(NSString*)cityId keyWord:(NSString*)keyWord page:(int)page pageSize:(int) pageSize{
    NSString* serviceName=@"GetSceneryList";
    
    NSString* requestHeader=[self getRequestHeader:serviceName];
    
    NSMutableString* requestXml=[[NSMutableString alloc]init];
    
    [requestXml appendString:@"<?xml version='1.0' encoding='utf-8' standalone='yes'?>"];
    [requestXml appendString:@"<request>"];
    [requestXml appendString:requestHeader];
    
    [requestXml appendString:@"<body>"];
    
    [requestXml appendFormat:@"<clientIp>%@</clientIp>",[LocalTravelConfig getClientIPForTongCheng]];
    if(cityId !=nil && ![cityId isEqualToString:@""]){
        [requestXml appendFormat:@"<cityId>%@</cityId>",cityId];
    }
    [requestXml appendFormat:@"<keyword>%@</keyword>",keyWord];
    [requestXml appendFormat:@"<searchFields>%@</searchFields>",@"sceneryName"];
    
    [requestXml appendFormat:@"<page>%d</page>",page];
    [requestXml appendFormat:@"<pageSize>%d</pageSize>",pageSize];
    [requestXml appendFormat:@"<cs>%@</cs>",@"2"];
    [requestXml appendString:@"</body>"];
    [requestXml appendString:@"</request>"];
    
    NSString *returnXml = [self sendRequest:requestXml];
return  returnXml   ;

}
/**
 获取景点评论
 */
+(NSString*)getSceneryComment:(NSString*)sceneryId{
    NSString* serviceName=@"GetCommentList";
    
    NSString* requestHeader=[self getRequestHeader:serviceName];
    
    NSMutableString* requestXml=[[NSMutableString alloc]init];
    
    [requestXml appendString:@"<?xml version='1.0' encoding='utf-8' standalone='yes'?>"];
    [requestXml appendString:@"<request>"];
    [requestXml appendString:requestHeader];
    
    [requestXml appendString:@"<body>"];
 
    [requestXml appendFormat:@"<sceneryId>%@</sceneryId>",sceneryId];
    
    
    [requestXml appendString:@"</body>"];
    [requestXml appendString:@"</request>"];
    
    NSString *returnXml = [self sendRequest:requestXml tongChengUrl:[LocalTravelConfig getTongChengCommentApiUrl]];
 return  returnXml   ;

}
@end
